<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>{{ num }}</strong></span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: isSel === 'isAll' }"
          href="javascript:;"
          @click="allList"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: isSel === 'no' }"
          href="javascript:;"
          @click="unfinished"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: isSel === 'yes' }"
          href="javascript:;"
          @click="finished"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="clearFinished">清除已完成</button>
  </footer>
</template>

<script>
import { mapMutations, mapState, mapGetters } from 'vuex'
export default {
  data() {
    return {}
  },
  computed: {
    ...mapState(['isSel']),
    ...mapGetters(['num']),
  },
  methods: {
    ...mapMutations(['unfinishedList', 'finishedList', 'allList', 'clear']),
    unfinished() {
      this.$store.commit('unfinishedList')
    },
    finished() {
      this.$store.commit('finishedList')
    },
    allList() {
      this.$store.commit('allList')
    },
    clearFinished() {
      this.$store.commit('clear')
    },
  },
}
</script>
